<div id="content">
	<div class="row s_page_title">
		<sa-big-breadcrumbs [items]="['项目管理','小程序管理[随你运]','资源管理']" icon="fa fa-smile-o" class="col-xs-12 col-sm-7 col-md-7 col-lg-4"></sa-big-breadcrumbs>
	</div>

	<sa-widgets-grid>
		<div class="s_table">
			<div sa-widget [editbutton]="false" color="darken" class="clearfix">
				<header>
					<span class="widget-icon"> <i class="fa fa-table"></i> </span>
					<h2>资源管理</h2>
				</header>
				<div>
					<div class="widget-body no-padding">
						<div class="page-header clearfix s_table_opreation">
							<div class="left page-header-btn">
								<div class="top_module top_module_box">
									<span class="top_module_label module_text">资源类型</span>
									<select name="" class="top_module_select" [(ngModel)]="resourceType" (change)='table_search()'>
										<option value="">全部</option>
										<option *ngFor="let item of typeList" [value]='item.value'>{{item.label}}</option>
									</select>
								</div>
								<button class="btn btn-primary" (click)="addResources(resourcesModal)" *ngIf="isShowAdd">添加</button>
							</div>
							<div class="right top-search">
								<input type="text" [(ngModel)]="searchKey" (change)="table_search()" class="search-input" placeholder="资源名称...">
								<span class="top-search-box">
							        <button class="top-search-btn" type="button" (click)="table_search()"> <i class="fa fa-search"></i></button>
							    </span>
							</div>
						</div>
						<div class="table_scroll">
							<table	class="display dataTables responsive table table-striped table-bordered table-hover dataTable s_h5_table">
								<thead>
									<tr>
										<th>编号</th>
										<th>资源名称</th>
										<th>默认状态</th>
										<th>上级名称</th>
										<th>资源标识</th>
										<th>资源类型</th>
										<th>创建时间</th>
										<th *ngIf="isShowDel || isShowEdit">操作</th>
									</tr>
								</thead>
								<tbody>
									<tr *ngFor="let row of tableData; let i = index" [attr.data-index]="i">
										<td>{{row.id}}</td>
										<td>{{row.name}}</td>
										<td *ngIf="isShowEdit" class="smart-form" style="padding: 7px 10px;">
											<input style="margin-right: 5px;display: none;" name="status" class="isEnable" type="checkbox" [checked]="row.isHide" [id]='row.id'>
										</td>
										<td *ngIf="!isShowEdit" class="smart-form" style="height:28px;line-height:28px;text-align: center;">
											<div class="mySwitch" *ngIf="row.isHide == '0'"><span class="white"></span><span class="closeText">关闭</span></div>
											<div class="mySwitch" *ngIf="row.isHide == '1'"><span  class="openText">开启</span><span class="white"></span></div>
										</td>
										<td>{{row.parentName}}</td>
										<td>{{row.sourceKey}}</td>
										<td>
											<span *ngIf="row.type == 0" class="green">菜单</span>
											<span *ngIf="row.type == 1" class="orange">按钮</span>
											<span *ngIf="row.type == 2" class="blue">字段</span>
										</td>
										<td>{{row.createTime}}</td>
										<td *ngIf="isShowDel || isShowEdit">
											<button *ngIf="isShowEdit" type="button" (click)="editResources(row, resourcesModal)">编辑</button>
											<button *ngIf="isShowDel" type="button" (click)="examineDelete(row)">删除</button>
										</td>
									</tr>
								</tbody>
							</table>
						</div>
						<div class="table-fix clearfix">
							<paginator [totalRecords]="totalCount" [rows]="pageSize" [currentPage]="curPage - 1" (onPageChange)="paginate($event)"></paginator>
							<button type="button" class="btn default refresh_btn" (click)="refresh()"><i class="fa fa-refresh"></i></button>
						</div>
					</div>
				</div>
			</div>
		</div>
	</sa-widgets-grid>
</div>

<!-- 新增审核人员   弹窗-->
<section bsModal #resourcesModal="bs-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
	<div class="modal-dialog modal-lg">
		<div class="modal-content" style="width: 700px;">
			<div class="modal-header">
				<h4 class="modal-title"><span *ngIf="pageType ==='new'">添加</span><span *ngIf="pageType ==='updata'">编辑</span>资源</h4>
			</div>
			<form id="resourceForm" class="form-horizontal" role="form" novalidate="novalidate" [saBootstrapValidator]="validatorOptions">
				<div class="modal-body">
					<div class="row form-horizontal">
						<div class="form-group col-xs-12">
							<label class="control-label col-sm-2 no-padding-right">资源类型<sup>*</sup></label>
							<div class="col-sm-10">
								<div class="clearfix">
									<select class="form-control" name="type" [(ngModel)]="page.type" [disabled]="resourceId?true:false" (change)="typeChange($event.target.value)"style="width: 100%">
										<option value="">请选择</option>
										<option *ngFor="let item of typeList" [value]='item.value'>{{item.label}}</option>
									</select>
								</div>
							</div>
						</div>
						<div class="form-group col-xs-12">
							<label class="control-label col-sm-2 no-padding-right">上级名称</label>
							<div class="col-sm-10 company_tree">
								<div class="clearfix" style="position: relative;">
									<div class="s_hover_box s_fix_radius" style="width: 100%;height: 32px;line-height: 32px;border-radius: 0;">
										<input class="form-control tree_company_input" id="company" name="parentId" autocomplete='off' 
											style="height: 32px!important;line-height: 32px;" onfocus="this.blur()"
											[(ngModel)]='selectMenus' (click)="companyClick()" type="text" placeholder="请选择" 
										/>
										<div class="s_del_icon" (click)='delText()' style="top:8px">x</div>
									</div>
									<div class="s_tree_box" id="tree_box" style="width: 100%;top: 32px;height:450px">
										<div class="treeSearchInputBox">
											<input type="text" class="treeSearchInput" (input)="companySearch()" placeholder="关键字"/>
											<i class="fa fa-search absoIcon" (click)="companySearchBtn()"></i>
										</div>
										<div class="vision_tree" id="vision_tree" style="height: 85%;">
											<!-- <div style="position: relative;left: -6px;"><i class="fa fa-home"></i><span class="s_company_root" (click)="companyRoot()">ROOT(根目录)</span></div> -->
											<div id="tree"></div>
										</div>
									</div>
								</div>
							</div>
						</div>
						<!-- 资源树形图 end-->
						<div class="form-group col-xs-12">
							<label class="control-label col-sm-2 no-padding-right">资源名称<sup>*</sup></label>
							<div class="col-sm-10">
								<div class="clearfix">
									<input class="form-control" name="name" [attr.resourceId]="resourceId" [(ngModel)]='page.name' type="text" placeholder="资源名称" />
								</div>
							</div>
						</div>
						
						<div class="form-group col-xs-12">
							<label class="control-label col-sm-2 no-padding-right" for="sourceKey">资源标识<sup>*</sup></label>
							<div class="col-sm-10">
								<div class="clearfix">
									<input class="form-control" name="sourceKey" type="text" [disabled]="resourceId?true:false" [(ngModel)]='page.sourceKey' placeholder="资源标识" />
								</div>
							</div>
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" (click)="resourcesClose(resourcesModal)">取消</button>
					<button type="submit" class="btn btn-primary" *ngIf='pageType == "new"' (click)="resourcesSubmit(resourcesModal)">添加</button>
					<button type="submit" class="btn btn-primary" *ngIf='pageType == "updata"' (click)="resourcesSubmit(resourcesModal)">保存</button>
				</div>
			</form>
		</div>
	</div>
</section>